export const InputMethod = GObject.registerClass({
Signals: {
'surrounding-text-set': {},
- 'terminal-mode-changed': {},
},
}, class InputMethod extends Clutter.InputMethod {
_init() {
this._preeditAnchor = 0;
this._preeditVisible = false;
this._hidePanelId = 0;
- this.terminalMode = false;
this._ibus = IBus.Bus.new_async();
this._ibus.connect('connected', this._onConnected.bind(this));
this._ibus.connect('disconnected', this._clear.bind(this));
this._surroundingTextCursor = null;
this._surroundingTextAnchor = null;
this._preeditStr = null;
- this._setTerminalMode(false);
}
vfunc_set_cursor_location(rect) {
IBus.InputPurpose.TERMINAL)
ibusPurpose = IBus.InputPurpose.TERMINAL;
- this._setTerminalMode(
- purpose === Clutter.InputContentPurpose.TERMINAL);
-
this._purpose = ibusPurpose;
if (this._context)
this._context.set_content_type(this._purpose, this._hints);
}
- _setTerminalMode(terminalMode) {
- if (this.terminalMode !== terminalMode) {
- this.terminalMode = terminalMode;
- this.emit('terminal-mode-changed');
- }
- }
-
vfunc_filter_key_event(event) {
if (!this._context)
return false;
this._updateKeys();
- Main.inputMethod.connectObject(
- 'terminal-mode-changed', this._onTerminalModeChanged.bind(this),
- this);
-
this._keyboardController.connectObject(
'active-group', this._onGroupChanged.bind(this),
'groups-changed', this._onKeyboardGroupsChanged.bind(this),
}
_ensureKeys() {
- const group = this._keyboardController.getCurrentGroup();
+ let group;
+ if (this._purpose === Clutter.InputContentPurpose.TERMINAL)
+ group = 'us-extended';
+ else
+ group = this._keyboardController.getCurrentGroup();
+
if (!this._groups[group])
this._groups[group] = this._createLayersForGroup(group);
}
if (enabled &&
(!Main.inputMethod.currentFocus ||
Main.inputMethod.hasPreedit() ||
- Main.inputMethod.terminalMode)) {
+ this._purpose === Clutter.InputContentPurpose.TERMINAL)) {
this._keyboardController.keyvalPress(Clutter.KEY_BackSpace);
this._backspacePressed = true;
return;
this._updateKeys();
}
- _onTerminalModeChanged() {
- this._updateKeys();
- }
-
_onKeyboardGroupsChanged() {
let nonGroupActors = [this._emojiSelection, this._keypad];
this._aspectContainer.get_children().filter(c => !nonGroupActors.includes(c)).forEach(c => {
}
getCurrentGroup() {
- if (Main.inputMethod.terminalMode)
- return 'us-extended';
-
// Special case for Korean, if Hangul mode is disabled, use the 'us' keymap
if (this._currentSource.id === 'hangul') {
const inputSourceManager = InputSourceManager.getInputSourceManager();